<!DOCTYPE html>
<html lang="en" class="bg-white" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>合同管理</title>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{../../assets/libs/layui/css/layui.css}"/>
    <link rel="stylesheet" th:href="@{../../assets/module/admin.css?v=311}"/>
</head>
<body>

<!-- 页面加载loading -->
<div class="page-loading">
    <div class="ball-loader">
        <span></span><span></span><span></span><span></span>
    </div>
</div>

<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-row">
        <div class="layui-col-xs12 layui-col-sm12 layui-col-lg6">
            <table class="layui-table">
                <colgroup>
                    <col width="100">
                    <col width="150">
                    <col width="100">
                    <col width="150">
                </colgroup>
                <tbody>
                <tr>
                    <td>商品编号</td>
                    <td id="productId"></td>
                    <td>商品标题</td>
                    <td id="productTitle"></td>
                </tr>
                <tr>
                    <td>联 系 人</td>
                    <td id="productNickName"></td>
                    <td>联系电话</td>
                    <td id="sys_cs_phone">*</td>
                </tr>
                <tr>
                    <td>商品现价</td>
                    <td id="productPrice"></td>
                    <td>商品原价</td>
                    <td id="productOldPrice"></td>
                </tr>
                <tr>
                    <td>商品类别</td>
                    <td id="productType"></td>
                    <td>交易方式</td>
                    <td id="tradeType"></td>
                </tr>
                <tr>
                    <td>发布时间</td>
                    <td id="gmtCreate"></td>
                    <td>最近更新</td>
                    <td id="gmtModified"></td>
                </tr>
                <tr>
                    <td>商品详情</td>
                    <td  colspan="3" id="productDetail"></td>
                </tr>
                </tbody>
            </table>
        </div>
        <div class="layui-col-xs12 layui-col-sm12 layui-col-lg6">
            <fieldset class="layui-elem-field">
                <legend>商品图片</legend>
                <div class="layui-field-box" style="text-align: center">
                    <div class="layui-upload-list layui-row layui-col-space10" id="demo2">

                    </div>
                </div>
            </fieldset>
        </div>
    </div>
</div>

<!-- js部分 -->
<script type="text/javascript" src="../../assets/libs/layui/layui.js"></script>
<script type="text/javascript" src="../../assets/js/common.js?v=311"></script>
<script>
    layui.use(['layer', 'form', 'table', 'util', 'laydate','printer','contextMenu'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var util = layui.util;
        var printer = layui.printer;
        var laydate = layui.laydate;
        var str=localStorage.getItem("projects");
        // 重写整个页面右键菜单
        $("html").dblclick(function(){
            printer.print();
        });
        $("tr td:nth-child(odd)").css("background-color","#f0ffff");
        function getProjectName(index) {
            var arr=str.split(",");
            return arr[index];
        }
        // 打印当前页面
        $('#btnPrint1').click(function () {
            printer.print();
        });
        $.ajax({
            type: "GET",
            url: "/product/"+localStorage.getItem("product_id"),
            dataType: "json",
            headers: {
                'token': "U2PGBjguSuJg"
            },
            success: function (data) {
                console.log(data)
                $("#productId").text(data.productId);
                $("#productNickName").text(data.wxInfo.nickName)
                $("#productPrice").text(data.productPrice)
                $("#productOldPrice").text(data.productOldPrice)
                $("#productTitle").text(data.productTitle)
                $("#productDetail").text(data.productDetail)
                $("#gmtCreate").text(data.gmtCreate)
                $("#gmtModified").text(data.gmtModified)
                $("#productType").text(data.productType)
                if (data.tradeType==0){
                    $("#tradeType").text("面交")
                } else {
                    $("#tradeType").text("邮寄")
                }
                for (var i=0;i<data.rsImageList.length;i++){
                    var  image=data.rsImageList[i].imgUrl;
                    $('#demo2').append('<div class="layui-col-sm6"><img class="openImg" style="width: 300px;height: 240px" src="'+ image +'"></div>')
                }

            }
        });
        function getSex(str){
            if (str==0){
                return "男";
            } else {
                return "女";
            }
        }
        $(document).on('click','.openImg',function () {
            var image=$(this).attr('src');
            layer.open({
                type: 1,
                title:"查看合同照",
                skin: 'layui-layer-rim', //加上边框
                area: ['600px', '450px'] //宽高
                ,shade: 0.3
                ,maxmin:true
                ,shadeClose:true,
                content: '<div class="layui-fluid" style="text-align: center"><img src="'+image+'" alt=""></div>'
            });
        })
    });
</script>

</body>
</html>